package net.minecraft.src;

import java.util.Random;

public class PPHGenVines extends WorldGenerator
{

    public PPHGenVines()
    {
    }

    public boolean generate(World world, Random random, int i, int j, int k)
    {
        for(int i1 = 0; i1 < 128; i1++)
        {
            int j1 = (i + random.nextInt(8)) - random.nextInt(8);
            int k1 = (j + random.nextInt(8)) - random.nextInt(8);
            int l1 = (k + random.nextInt(8)) - random.nextInt(8);
            if(world.isAirBlock(j1, k1, l1))
            {
			if(world.getBlockMaterial(j1 + 1, k1, l1).isSolid() && world.getBlockId(j1 + 1, k1, l1) != mod_pph.algae.blockID)
			{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 8);
			}
			if(world.getBlockMaterial(j1 - 1, k1, l1).isSolid() && world.getBlockId(j1 - 1, k1, l1) != mod_pph.algae.blockID)
			{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 2);
			}
			if(world.getBlockMaterial(j1, k1, l1 + 1).isSolid() && world.getBlockId(j1, k1, l1 + 1) != mod_pph.algae.blockID)
			{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 1);
			}
			if(world.getBlockMaterial(j1, k1, l1 - 1).isSolid() && world.getBlockId(j1, k1, l1 - 1) != mod_pph.algae.blockID)
			{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 4);
			}
			
			if(world.getBlockId(j1 + 1, k1 + 1, l1) == mod_pph.prehistoricVine.blockID && world.getBlockMetadata(j1 + 1, k1 + 1, l1) == 8)
			{
				if(random.nextInt(2) == 0)
				{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 8);
				}
			}
			if(world.getBlockId(j1 - 1, k1 + 1, l1) == mod_pph.prehistoricVine.blockID && world.getBlockMetadata(j1 - 1, k1 + 1, l1) == 2)
			{
				if(random.nextInt(2) == 0)
				{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 2);
				}
			}
			if(world.getBlockId(j1, k1 + 1, l1 + 1) == mod_pph.prehistoricVine.blockID && world.getBlockMetadata(j1, k1 + 1, l1 + 1) == 1)
			{
				if(random.nextInt(2) == 0)
				{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 1);
				}
			}
			if(world.getBlockId(j1, k1 + 1, l1 - 1) == mod_pph.prehistoricVine.blockID && world.getBlockMetadata(j1, k1 + 1, l1 - 1) == 4)
			{
				if(random.nextInt(2) == 0)
				{
				world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, 4);
				}
			}
        }
		int l = world.getBlockMetadata(j1, k1 + 1, l1);
		if(world.isAirBlock(j1, k1, l1) && world.getBlockId(j1, k1 + 1, l1) == mod_pph.prehistoricVine.blockID)
		{
			world.setBlockAndMetadata(j1, k1, l1, mod_pph.prehistoricVine.blockID, l);
		}
		}

        return true;
    }
}
